package com.example.teesystem.common.utils;
import lombok.experimental.UtilityClass;

import java.util.HashMap;
import java.util.Map;

@UtilityClass
public class EstimateGenerate {

    //通过分数区间判别学生等级
    public Map<Integer, String> LevelJudge(float judgeScore){
        int level;

        if(judgeScore >= 4) {
            level = 5;
        } else if(judgeScore >=3) {
            level = 4;
        } else if(judgeScore >=2) {
            level = 3;
        } else if(judgeScore >=1) {
            level = 2;
        } else if(judgeScore >= 0) {
            level = 1;
        } else {
            level = -1;
        }
        Map<Integer, String> levelMap = new HashMap<>();
        levelMap.put(level, getLevelMessage(level));
        return levelMap;
    }

    //获取对学生的最终评价信息
    public String getLevelMessage(int level){
        if(level == 5) {
            return "优秀";
        } else if(level == 4) {
            return "良好";
        } else if(level == 3) {
            return "中等";
        } else if(level == 2) {
            return "较差";
        } else if(level == 1) {
            return "很差";
        } else {
            return "数据不足，无法评价";
        }
    }

    public static double sigmoidF(double x) {
        return 1f / (1f + Math.pow(Math.E, -1 * x));
    }


}
